/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bolao.ui.beans;

import bolao.dominio.Categoria;
import bolao.dominio.Item;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author 002824992500
 */
@ManagedBean
@ViewScoped
public class ItemJSFBean extends BaseCRUDJSFBean {

    private static final Logger log = LoggerFactory.getLogger(ItemJSFBean.class);

    //private static final Logger log = Logger.getLogger(ItemJSFBean.class.getName());


    public Item getItem() {        
        return getObjSelecionado();
    }

    public void setItem(Item item) {
        setObjSelecionado(item);
    }

    private List<Item> itens = new ArrayList<Item>();

    public List<Item> getItens() {
        return itens;
    }
    
    private List<Categoria> categorias = new ArrayList<Categoria>();

    public List<Categoria> getCategorias() {
        return categorias;
    }

    /** Creates a new instance of ColaboradorJSFBean */
    public ItemJSFBean() {
    }

    @Override
    public void setup() {        
        try {
            renovarTabela();
            this.categorias = getCrudService().findAll(Categoria.class);

            setPaginaForm("form_item");
            setPaginaListagem("list_item");
            setCrudClass(Item.class);
        } catch (Exception e) {
            String err = "Erro na inicialização: " + e.getMessage();
            error(err);
            //log.error(err, e);
        }        
    }

    @Override
    protected void renovarTabela() {        
        this.itens = getCrudService().findAll(Item.class);
    }    

}
